const express = require('express') // 第三方
const {userRouter} = require('./router/users')  // 引入自定义
const {goodsRouter} = require('./router/goods')
const {bannerRouter} = require('./router/banner')
const {categoryRouter} = require('./router/category')
const cors = require('cors')

const app = express() // express实例对象

//集成cors中间件
app.use(cors())

//post请求body参数
app.use(express.json()) // 处理json格式数据  {username:admin}
app.use(express.urlencoded({extended:false})) // 处理key-value username=admin

app.use(userRouter) // 集成路由
app.use(goodsRouter)
app.use(bannerRouter)
app.use(categoryRouter)

app.listen(3000,console.log('监听3000端口，启动服务...'))
